﻿using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using GameClient;
using Protocol;
using Protocol.DTO;

public class NetIOUtil : MonoBehaviour {
    NetIO io;
    IMessageHandle login;
    
    //User_DTO dto = new User_DTO();
	// Use this for initialization
	void Start () {
        io = NetIO.instance;
        login = GetComponent<LoginHandler>();
        //dto.username="wu";
        //dto.password="123123";
        //this.SendModel(new TransModel(GameProtocol.login, 1, Protocol.LoginProtocol.Login_CREQ, dto));
	}
	
	// Update is called once per frame
    /// <summary>
    /// 判断模型中是否有消息，有，则将模型提取出来
    /// </summary>
	void Update () {
        if (io.models.Count > 0)
        {
            TransModel model = io.models[0];
            switch (model.type)
            {
                case GameProtocol.login:
                    login.OnMessageReceive(model);
                    break;
                default:
                    break;
            }
            io.models.RemoveAt(0);
        }
	}
}
